#pragma once

#include <QObject>
#include "poco/user.h"

namespace WordMemory
{
    class UserManager : public QObject
    {
        Q_OBJECT

    public:
        static UserManager &instance()
        {
            static UserManager inst;
            return inst;
        }


        void setCurrentUser(const User &user);
        User getCurrentUser() const;

        // 获取特定字段
        int getUserId() const;
        QString getUsername() const;
        QString getRealName() const;
        QString getCreatedAt() const;


        bool isLoggedIn() const;
        void clearUser();

    signals:
        void userChanged(const User &user);
        void userCleared();

    private:
        UserManager();
        UserManager(const UserManager &) = delete;
        UserManager &operator=(const UserManager &) = delete;

        User currentUser;
        bool loggedIn;
    };
}
